package com.job.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.job.common.ResponseResult;
import com.job.common.exception.ParameterIsNullException;
import com.job.common.exception.UserException;
import com.job.controller.req.PageVo;
import com.job.controller.req.PositionSearchVO;
import com.job.service.PositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@Api("职位管理")
@RequestMapping("/position")
public class PositionController {

    @Resource
    private PositionService positionService;

    @ApiOperation("职位搜索")
    @GetMapping("/search")
    public ResponseResult<IPage<Map<String,Object>>> positionSearch(PositionSearchVO positionSearchVO)
            throws ParameterIsNullException {
        return positionService.positionSearch(positionSearchVO);
    }

    @ApiOperation("职位列表")
    @GetMapping("/positionList")
    public ResponseResult<IPage<Map<String,Object>>> positionList(PageVo page) throws ParameterIsNullException {
        PositionSearchVO positionSearchVO = new PositionSearchVO(page.getCurrent(),page.getSize());
        return positionService.positionSearch(positionSearchVO);
    }

    @ApiOperation("职位详情")
    @GetMapping("/context")
    public ResponseResult<Map<String,Object>> positionContext(@NotNull Integer positionId)
            throws ParameterIsNullException, UserException {
        return positionService.positionInfoContext(positionId);
    }
}
